package datatypes;

import static org.junit.Assert.*;
import junit.framework.JUnit4TestAdapter;

import org.junit.Before;
import org.junit.Test;

public class Triangle_test {
	
	public static junit.framework.Test suite() {
		return new JUnit4TestAdapter(Triangle_test.class);
	}

	@Before
	public void setUp() throws Exception {
	}

//	@Test
//	public void testContainsEdge() {
//		fail("Not yet implemented");
//	}
//
//	@Test
//	public void testGetCircumferenceLength() {
//		fail("Not yet implemented");
//	}
//
//	@Test
//	public void testGetEdge() {
//		fail("Not yet implemented");
//	}
//
//	@Test
//	public void testIsEmpty() {
//		fail("Not yet implemented");
//	}
//
//	@Test
//	public void testGetVertexNotOnEdge() {
//		fail("Not yet implemented");
//	}

	@Test
	public void testHeight() throws Exception {
		Vertex v1 = new Vertex(0.0, 0.0);
		Vertex v2 = new Vertex(2.0, 0.0);
		Vertex v3 = new Vertex(1.0, 2.0);
		
		Edge base = new Edge(v1, v2);
		Triangle t = new Triangle(base, new Edge(v1, v3), new Edge(v2, v3), true);
		assertEquals("Height", 2.0, t.height(base), 0.00001);
	}
	
	@Test
	public void testHeight2() throws Exception {
		Vertex v1 = new Vertex(0.0, 0.0);
		Vertex v2 = new Vertex(2.0, 0.0);
		Vertex v3 = new Vertex(1000000.0, -7.0);
		
		Edge base = new Edge(v1, v2);
		Triangle t = new Triangle(base, new Edge(v1, v3), new Edge(v2, v3), true);
		assertEquals("Height", 7.0, t.height(base), 0.00001);
	}
	
	@Test
	public void testHeight3() throws Exception {
		Vertex v1 = new Vertex(2.0, 0.0);
		Vertex v2 = new Vertex(0.0, 2.0);
		Vertex v3 = new Vertex(2.0, 2.0);
		
		Edge base = new Edge(v1, v2);
		Triangle t = new Triangle(base, new Edge(v1, v3), new Edge(v2, v3), true);
		assertEquals("Height", Math.sqrt(2.0), t.height(base), 0.00001);
	}

}
